/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package edu.cmu.mism.dgjava.data.models.option.impl;

import edu.cmu.mism.dgjava.data.models.option.Index;
import edu.cmu.mism.dgjava.data.models.option.OptionModelPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Index</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link edu.cmu.mism.dgjava.data.models.option.impl.IndexImpl#getIndexLevel <em>Index Level</em>}</li>
 *   <li>{@link edu.cmu.mism.dgjava.data.models.option.impl.IndexImpl#getDividendYield <em>Dividend Yield</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class IndexImpl extends DerivitivesImpl implements Index {
	/**
	 * The default value of the '{@link #getIndexLevel() <em>Index Level</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIndexLevel()
	 * @generated
	 * @ordered
	 */
	protected static final int INDEX_LEVEL_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getIndexLevel() <em>Index Level</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIndexLevel()
	 * @generated
	 * @ordered
	 */
	protected int indexLevel = INDEX_LEVEL_EDEFAULT;

	/**
	 * The default value of the '{@link #getDividendYield() <em>Dividend Yield</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDividendYield()
	 * @generated
	 * @ordered
	 */
	protected static final double DIVIDEND_YIELD_EDEFAULT = 0.0;

	/**
	 * The cached value of the '{@link #getDividendYield() <em>Dividend Yield</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDividendYield()
	 * @generated
	 * @ordered
	 */
	protected double dividendYield = DIVIDEND_YIELD_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IndexImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return OptionModelPackage.Literals.INDEX;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getIndexLevel() {
		return indexLevel;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setIndexLevel(int newIndexLevel) {
		int oldIndexLevel = indexLevel;
		indexLevel = newIndexLevel;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OptionModelPackage.INDEX__INDEX_LEVEL, oldIndexLevel, indexLevel));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public double getDividendYield() {
		return dividendYield;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDividendYield(double newDividendYield) {
		double oldDividendYield = dividendYield;
		dividendYield = newDividendYield;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OptionModelPackage.INDEX__DIVIDEND_YIELD, oldDividendYield, dividendYield));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case OptionModelPackage.INDEX__INDEX_LEVEL:
				return getIndexLevel();
			case OptionModelPackage.INDEX__DIVIDEND_YIELD:
				return getDividendYield();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case OptionModelPackage.INDEX__INDEX_LEVEL:
				setIndexLevel((Integer)newValue);
				return;
			case OptionModelPackage.INDEX__DIVIDEND_YIELD:
				setDividendYield((Double)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case OptionModelPackage.INDEX__INDEX_LEVEL:
				setIndexLevel(INDEX_LEVEL_EDEFAULT);
				return;
			case OptionModelPackage.INDEX__DIVIDEND_YIELD:
				setDividendYield(DIVIDEND_YIELD_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case OptionModelPackage.INDEX__INDEX_LEVEL:
				return indexLevel != INDEX_LEVEL_EDEFAULT;
			case OptionModelPackage.INDEX__DIVIDEND_YIELD:
				return dividendYield != DIVIDEND_YIELD_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (indexLevel: ");
		result.append(indexLevel);
		result.append(", dividendYield: ");
		result.append(dividendYield);
		result.append(')');
		return result.toString();
	}

} //IndexImpl
